using UnityEngine;

namespace ZFramework.Runtime
{
    public class EntityInstanceObject : ObjectBase
    {
        private IResourceMgr _resourceMgr;
        //private Object _entityAsset;

        public override void Release()
        {
            Object.Destroy((Object)Instance);
            _resourceMgr.UnloadAsset(Name);
        }

        public static EntityInstanceObject Create(string name, Object entityAsset, Object entityInstance, IResourceMgr resourceMgr)
        {
            var entityObject = ReferencePool.Acquire<EntityInstanceObject>();
            entityObject.Initialize(name, entityInstance);
            //entityObject._entityAsset = entityAsset;
            entityObject._resourceMgr = resourceMgr;
            return entityObject;
        }

        public override void Clear()
        {
            base.Clear();
            //_entityAsset = null;
        }

    }
}